/*
 * @Author: HZK
 * @Date: 2020-09-22 18:36:41
 * @LastEditTime: 2020-09-22 20:21:15
 * @LastEditors: hanfengmi
 * @Description: 
 */
const {merge} = require('webpack-merge');
const baseConfig = require('./webpack.common.js'); // 引用公共的配置
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsWebpackPlugin = require('optimize-css-assets-webpack-plugin');

const prodConfig = {
    mode: 'production',
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                ]
            },
            {
                test: /\.less$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                    'less-loader',
                ]
            }
        ]
    },
    plugins: [
        new CleanWebpackPlugin(), 
        new MiniCssExtractPlugin(),
        new OptimizeCssAssetsWebpackPlugin()
    ]
}

module.exports = merge(prodConfig, baseConfig); // 将baseConfig和prodConfig合并为一个配置
